using Gateway.Domain.EFCore.Configuration;
using Gateway.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Gateway.Domain.Configuration;

public class DescribeDomainRecordConfiguration : EntityConfiguration<DescribeDomainRecord>
{
    public override void Configure(EntityTypeBuilder<DescribeDomainRecord> builder)
    {
        builder.ToTable(t => t.HasComment("阿里的域名解析记录表"));
        builder.Property(x => x.Status).HasColumnName("status").HasMaxLength(100);
        builder.Property(x => x.Type).HasColumnName("type").HasMaxLength(100);
        builder.Property(x => x.Remark).HasColumnName("remark").HasMaxLength(100);
        builder.Property(x => x.TTL).HasColumnName("ttl");

        builder.Property(x => x.RecordId).HasColumnName("recordId").HasMaxLength(100);
        builder.Property(x => x.RR).HasColumnName("rr").HasMaxLength(100);
        builder.Property(x => x.DomainName).HasColumnName("domainName").HasMaxLength(500);
        builder.Property(x => x.Weight).HasColumnName("weight");
        builder.Property(x => x.Value).HasColumnName("value").HasMaxLength(500);
        builder.Property(x => x.Endpoint).HasColumnName("endpoint").HasMaxLength(100);
        builder.Property(x => x.DomainId).HasColumnName("domainId").HasMaxLength(50);
        builder.HasOne(x => x.Domain)
            .WithMany(x => x.Records)
            .HasForeignKey(x => x.DomainId)
            .OnDelete(DeleteBehavior.Cascade);
        base.Configure(builder);
    }
}